package com.seadragon.apps.doctorcard.model;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Type;

import com.vividsolutions.jts.geom.Point;

@Entity
@Table(name = "chat_message")
public class ChatMessage {
	@Id
	@Column(name = "ID")
	@GeneratedValue(strategy = GenerationType.AUTO)
	private long id;

	@ManyToOne
	@JoinColumn(name="CHAT_ID")
	private Chat chat;
	
	@ManyToOne(cascade=CascadeType.ALL)
	@JoinColumn(name="MESSAGE_ID")
	private Message message;
	
	@Column(name="DATE_PUBLISHED")
	private Date datePublished;

	@Column(name = "LOCATION")
    @Type(type = "org.hibernate.spatial.GeometryType")
    private Point location;

	@ManyToOne
	@JoinColumn(name="PUBLISHER_ID")
	private Contact publisher;
	
	public ChatMessage(){}
	
	public ChatMessage(Chat chat, Message message){
		this.chat = chat;
		this.message = message;
	}
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public Date getDatePublished() {
		return datePublished;
	}

	public void setDatePublished(Date datePublished) {
		this.datePublished = datePublished;
	}

	public Chat getChat() {
		return chat;
	}

	public void setChat(Chat chat) {
		this.chat = chat;
	}

	public Message getMessage() {
		return message;
	}

	public void setMessage(Message message) {
		this.message = message;
	}

	public Contact getPublisher() {
		return publisher;
	}

	public void setPublisher(Contact publisher) {
		this.publisher = publisher;
	}

	public Point getLocation() {
		return location;
	}

	public void setLocation(Point location) {
		this.location = location;
	}

}
